package com.google.zxing.client.ohos.camera;

import com.asher.zxingmodule.BaseAbility;
import com.google.zxing.Result;
import ohos.eventhandler.EventHandler;
import ohos.eventhandler.EventRunner;
import ohos.eventhandler.InnerEvent;

public class ScanAbilityHandler extends EventHandler {
    public static final int DECALDSUCCESS = 1001;
    public static final int DECALDFAIL = 1002;
    public static final int SHOURESULT = 1003;
    private BaseAbility ability;
    public ScanAbilityHandler(EventRunner runner,BaseAbility ability) throws IllegalArgumentException {
        super(runner);
        this.ability = ability;
    }

    @Override
    protected void processEvent(InnerEvent event) {
        super.processEvent(event);
        switch (event.eventId){
            case DECALDSUCCESS:
                Result result = (Result) event.object;
                ability.onDecodeSuccess(result);
                break;
            case DECALDFAIL:
                ability.onDecodeFail();
                break;
            case SHOURESULT:
                ability.triContinue();
                break;
        }
    }
}
